package com.admin.controller;

import com.admin.service.FeeService;
import com.admin.entity.Fee;
import com.admin.sys.base.module.extend.web.BaseController;
import com.admin.sys.base.entity.ResultInfo;
import com.admin.sys.utils.admin.StringUtils;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
*【费用信息】页面接口
*/
@RestController
@RequestMapping("/admin/fee")
public class FeeController extends BaseController {

    @Autowired
    private FeeService feeService;

    /**
    * 【费用信息】根据条件分页查询
    * @param page
    * @param fee
    * @return
    */
    @RequestMapping("/getPage")
    public ResultInfo getPage(Page<Fee> page, Fee fee) {
        IPage<Fee> iPage = feeService.getPage(page, fee);
        return ResultInfo.ok("获取分页成功", iPage);
    }

    /**
    * 【费用信息】根据条件查询
    * @param fee
    * @return
    */
    @RequestMapping("/getList")
    public ResultInfo getList(Fee fee) {
        List<Fee> list = feeService.getList(fee);
        return ResultInfo.ok("获取列表成功", list);
    }

    /**
    * 【费用信息】根据对象查询
    * @param fee
    * @return
    */
    @RequestMapping("/get")
    public ResultInfo get(Fee fee) {
        Fee entity = feeService.get(fee);
        return ResultInfo.ok("获取对象成功", entity);
    }

    /**
    * 【费用信息】提交(新增或修改)
    * @param fee
    * @return
    */
    @RequestMapping("/sub")
    public ResultInfo insert(Fee fee) {
        if (StringUtils.isEmpty(fee.getId())) { //新增
            feeService.insert(fee);
        } else {//修改
            feeService.update(fee);
        }
        return ResultInfo.ok("提交成功!");
    }

    /**
    * 【费用信息】删除
    * @param id
    * @return
    */
    @RequestMapping("/delete")
    public ResultInfo delete(String id) {
        feeService.delete(id);
        return ResultInfo.ok("删除成功!");
    }

    /**
    * 【费用信息】批量删除
    * @param ids
    * @return
    */
    @RequestMapping("/delAll")
    public ResultInfo delAll(String[] ids) {
        feeService.delAll(ids);
        return ResultInfo.ok("批量删除成功！");
    }



}



